package com.restaurant.validators;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import com.restaurant.domain.Menucategory;

public class MenuCategoryValidator implements Validator{
	
	@Override
	public boolean supports(Class<?> arg0) {
		return Menucategory.class.isAssignableFrom(arg0);
	}

	@Override
	public void validate(Object arg0, Errors errors) {
		
		//ValidationUtils.rejectIfEmptyOrWhitespace(errors, "menucategoryname", "menu.category");
		Menucategory menucategory = (Menucategory) arg0;
		
		
		if(menucategory.getMenucategoryname().trim().length() <= 0){
			errors.rejectValue("menucategoryname", "menu.category");
		}
		
	}

}
